package cn.wxManage.goodsManage.controller;

import cn.common.common.model.ServerResponse;
import cn.common.goods.model.BaseGoodsStyle;
import cn.wxManage.goodsManage.model.GoodsStyle;
import cn.wxManage.goodsManage.service.IGoodsStyleManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by Zhang on 2018/11/27.
 */
@RestController
@RequestMapping("/goodsStyle")
@Api(value="商品款式相关方法",description = "商品款式相关方法")
public class GoodsStyleManageController {
    @Autowired
    IGoodsStyleManageService iGoodsStyleManageService;

    @ApiOperation(value="根据款式编号获取指定商品的款式信息", notes="根据款式编号获取指定商品的款式信息",
            produces = "application/json")
    @GetMapping(value = "/getGoodsStyleByCode/{code}")
    public ServerResponse<?> getGoodsStyleByCode(@PathVariable("code") String code){
        return iGoodsStyleManageService.getGoodsStyleByCode(code);
    }

    @ApiOperation(value="根据商品ID获取下属所有款式", notes="根据商品ID获取下属所有款式",produces = "application/json")
    @GetMapping(value = "/getGoodsStyleById/{goodsId}")
    public ServerResponse<?> getGoodsStyleById(@PathVariable("goodsId") Integer goodsId){
        return iGoodsStyleManageService.getGoodsStyleById(goodsId);
    }

    @ApiOperation(value="根据款式ID获取款式信息以及上属商品信息", notes="根据款式ID获取款式信息以及上属商品信息",produces = "application/json")
    @GetMapping(value = "/getGoodsByStyleId/{goodsStyleId}")
    public ServerResponse<?> getGoodsByStyleId(@PathVariable("goodsStyleId") Integer goodsStyleId){
        return iGoodsStyleManageService.getGoodsByStyleId(goodsStyleId);
    }

    @ApiOperation(value="更新库存余量", notes="更新库存余量",produces = "application/json")
    @PutMapping(value = "/updateGoodsStyleBalance")
    public ServerResponse<?> updateGoodsStyleBalance(@RequestBody GoodsStyle goodsStyle){
        return iGoodsStyleManageService.updateGoodsStyleBalance(goodsStyle);
    }
}
